#begin
	CC=arm-elf-gcc
	LD=arm-elf-ld
	CFLAGS= -c -Wall -I./boot -O2 -pipe -g -mapcs-32 -march=armv4 -mtune=arm7tdmi -mshort-load-bytes
	LDFLAGS= -nostdlib -Bstatic -Tucos.lds
	LIBGCC = $(shell $(CC) -msoft-float -print-libgcc-file-name)
	LIB=
	OBJECTS= Startup.o target.o IRQ.o Os_cpu_c.o Os_cpu_a.o OS_CORE.o OS_MBOX.o OS_MUTEX.o OS_SEM.o OS_TIME.o OS_MEM.o OS_Q.o OS_TASK.o OS_FLAG.o uart0.o queue.o main.o

all:boot.bin
boot.bin: $(OBJECTS)
	$(LD) $(LDFLAGS) $(OBJECTS)  /usr/local/arm-elf/lib/libc.a  $(LIBGCC) -o start
	arm-elf-objcopy -O binary start boot.bin
	cp start ./binary
	cp boot.bin ./binary
main.o:boot/main.c
	$(CC) $(CFLAGS) boot/main.c
Startup.o:boot/Startup.s
	$(CC) $(CFLAGS) boot/Startup.s
target.o:boot/target.c boot/target.h
	$(CC) $(CFLAGS) boot/target.c
IRQ.o:boot/IRQ.s
	$(CC) $(CFLAGS) boot/IRQ.s
Os_cpu_c.o:arm/Os_cpu_c.c
	$(CC) $(CFLAGS) arm/Os_cpu_c.c
Os_cpu_a.o:arm/Os_cpu_a.s
	$(CC) $(CFLAGS) arm/Os_cpu_a.s
OS_CORE.o:SOURCE/OS_CORE.C
	$(CC) $(CFLAGS) SOURCE/OS_CORE.C
OS_MBOX.o:SOURCE/OS_MBOX.C
	$(CC) $(CFLAGS) SOURCE/OS_MBOX.C
OS_MUTEX.o:SOURCE/OS_MUTEX.C
	$(CC) $(CFLAGS) SOURCE/OS_MUTEX.C
OS_SEM.o:SOURCE/OS_SEM.C
	$(CC) $(CFLAGS) SOURCE/OS_SEM.C
OS_TIME.o:SOURCE/OS_TIME.C
	$(CC) $(CFLAGS) SOURCE/OS_TIME.C
OS_FLAG.o:SOURCE/OS_FLAG.C
	$(CC) $(CFLAGS) SOURCE/OS_FLAG.C
OS_MEM.o:SOURCE/OS_MEM.C
	$(CC) $(CFLAGS) SOURCE/OS_MEM.C
OS_Q.o:SOURCE/OS_Q.C
	$(CC) $(CFLAGS) SOURCE/OS_Q.C
OS_TASK.o:SOURCE/OS_TASK.C
	$(CC) $(CFLAGS) SOURCE/OS_TASK.C
uart0.o:boot/uart0.c boot/uart0.h
	$(CC) $(CFLAGS) boot/uart0.c
queue.o:boot/queue.c boot/queue.h
	$(CC) $(CFLAGS) boot/queue.c

clean:
	rm -rf *.o *.elf *.gdb hello *.r *.n *.s
	rm -f boot.bin
	rm -f start
	rm -f ./binary/boot.bin
	rm -f ./binary/start
	rm -f *.log
	rm -f *~
	rm -f ./arm/*~
	rm -f ./boot/*~
	rm -f ./SOURCE/*~
#end

